package airthmetic.exercise.arr;

public class _面试题10_01_合并排序的数组 {
    public void merge(int[] A, int m, int[] B, int n) {
        if (A == null || m == 0) {
            System.arraycopy(B, 0, A, 0, n);
            return;
        }
        if (B == null || n == 0) {
            return;
        }
        int current = A.length - 1;
        m = m-1;
        n = n-1;
        while (m >= 0 && n >= 0) {
            if (A[m] > B[n]) {
                A[current] = A[m];
                current--;
                m--;
            } else {
                A[current] = B[n];
                current--;
                n--;
            }
        }


        while(n >=0){
            A[current] = B[n];
            current--;
            n--;
        }
    }
}
